package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.linlinjava.litemall.admin.service.AdminMinioStroageService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@Api(tags = "Minio存储API")
@RestController
@RequestMapping("/admin/minio")
@RequiredArgsConstructor
public class AdminMinioStroageController extends ResponseUtil{
    private final AdminMinioStroageService adminMinioStroageService;
    @ApiOperation("Minio-「上传｜返回缩略图」")
    @PostMapping("/upload")
    public Response upload( @RequestParam("file")MultipartFile multipartfile) {
        return adminMinioStroageService.upload(multipartfile);
    }
    @ApiOperation("Minio-「下载｜文件」")
    @SneakyThrows
    @GetMapping("/download")
    public Response download(String filePath) {
        return adminMinioStroageService.download(filePath);
    }

    @ApiOperation("Minio-「删除｜文件」")
    @GetMapping("/delete")
    public Response delete(String filePath) {
        return adminMinioStroageService.delete(filePath);
    }

}
